<template>
  <div class="param-main">
    <el-form ref="tblMain" :model="tblMain" labelPosition="right" inline="" label-suffix=":" label-width="100px">
<!--`      <el-row :span="24">-->
<!--        <el-col :span="6">-->
<!--          <el-form-item label="时间类型">-->
<!--            <el-select v-model="tblMain.param.dateType" size="small" placeholder="请选择时间类型" style="width: 100%">-->
<!--              <el-option label="日" value="0" />-->
<!--              <el-option label="周" value="1" />-->
<!--              <el-option label="月" value="2" />-->
<!--            </el-select>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--      </el-row>`-->
      <div class="page-pane2">
        <el-button type="primary" size="small" @click="initTableData()">查询</el-button>
        <el-button size="small" @click="dataReset()">清空</el-button>
      </div>
    </el-form>
    <div>
      <el-table ref="tblMain" style="margin-top: 10px;" :data="tblMain.items" v-loading.body="tblMain.loading" border
        stripe>
        <el-table-column type="index" width="80" label="序号" align="center"></el-table-column>
        <el-table-column prop="incomeTotal" label="总收入" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column prop="masterTotal" label="养护收入" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column prop="themeTotal" label="主题套餐收入" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column prop="expendTotal" label="总支出" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column prop="regularTotal" label="固定支出" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column prop="laborCostTotal" label="人工费用支出" align="center" show-overflow-tooltip></el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import tool from '@/tool'
import {
  incomeAndExpenditure
} from '@/api/businessExtend';
import {
  getDictionaryItemMap
} from "@/api/common";
export default ({
  name: 'IncomeAndExpenditureList',
  data () {
    return {
      tblMain: tool.genTableData({
        param: {
          dateType: '0',
          itemType: ''
        },
        items: []
      }),
      themeTypeList: [],
    }
  },
  mounted () {
    this.init();
    this.initTableData();
  },
  methods: {
    init () {
      getDictionaryItemMap({ codeArr: "itemType" }).then((res) => {
        let data = res.data;
        if (data && data.code == 0) {
          this.themeTypeList = data.data.itemType;
        }
      });
    },
    dataReset () {
      this.tblMain.currentPage = 1
      this.tblMain.pageSize = 10
      this.tblMain.param.dateType = '0'
      this.tblMain.param.itemType = ''
      this.initTableData()
    },
    handleSizeChange (val) {
      this.tblMain.pageSize = val
      this.initTableData()
    },
    handleCurrentChange (val) {
      this.tblMain.currentPage = val
      this.initTableData()
    },
    initTableData () {
      let me = this
      let param = {
        dateType: me.tblMain.param.dateType,
        itemType: me.tblMain.param.itemType,
        page: me.tblMain.currentPage,
        size: me.tblMain.pageSize
      }
      me.tblMain.loading = true
      incomeAndExpenditure(param).then(res => {
        me.tblMain.loading = false
        let data = res.data
        if (data && data.code == 0) {
          me.tblMain.items = data.data
          // me.tblMain.total = data.data.total
        }
      })
    },
  }
})
</script>
